/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test.cei.jpah2database;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Francisco
 */
@Entity
@Table(name = "tbl_personas")
@NamedQueries({
    @NamedQuery(name = "buscarPersonaPorNombre",
    query = "SELECT p FROM Persona p WHERE p.nombre LIKE :nombre"),
    @NamedQuery(name = "buscarPersonaPorId",
    query = "SELECT p FROM Persona p WHERE p.id = :idPersona")})
public class Persona implements Serializable {

    private int id;
    private String nombre;
    private String apellido;
    private List<Persona> contactos;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int getId() {
	return id;
    }

    public void setId(int id) {
	this.id = id;
    }

    @Column(unique = true)
    public String getNombre() {
	return nombre;
    }

    public void setNombre(String nombre) {
	this.nombre = nombre;
    }

    public String getApellido() {
	return apellido;
    }

    public void setApellido(String apellido) {
	this.apellido = apellido;
    }

    @Transient
    public void getEdad(){
        
    }
    
    @Override
    public String toString() {
	return this.id + " - " + this.nombre + " - " + this.apellido;
    }
}
